From e0b8aeb3f44871d5d76c43722531975fcb09b4ad Mon Sep 17 00:00:00 2001 From: robertlipe Date: Tue, 16 Dec 2014 15:49:54 +0000 Subject: [PATCH] Don't hang on malformed UTF-16 input. --- gpsbabel/gbfile.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gpsbabel/gbfile.cc b/gpsbabel/gbfile.cc index 4afd6e990..22fc16b40 100644 --- a/gpsbabel/gbfile.cc +++ b/gpsbabel/gbfile.cc @@ -22,6 +22,7 @@ #include "defs.h" #include "gbfile.h" +#include "src/core/logging.h" #include #include @@ -1083,6 +1084,10 @@ gbfgetucs2str(gbfile* file) } clen = cet_ucs4_to_utf8(buff, sizeof(buff), c0); + if (clen < 1) { + Warning() << "Malformed UCS character" << c0 << "found."; + return NULL; + } if (len+clen >= file->buffsz) { file->buffsz += 64; -- 2.30.2